#include "mainwindow.h"
#include <QMessageBox>
#include <QMenu>
#include <QMenuBar>
#include <QToolBar>
#include "centralwidget.h"

MainWindow::MainWindow() : QMainWindow(NULL)
{
    m_all = new QAction("ALL", this);
    m_summer = new QAction("Summer", this);
    m_winter = new QAction("Winter", this);
    m_fall = new QAction("Fall", this);
    m_spring = new QAction("Spring", this);

    QMenu * menu = new QMenu("Actions", this);
    menu->addAction(m_all);
    menu->addSeparator();
    menu->addAction(m_summer);
    menu->addAction(m_winter);
    menu->addAction(m_fall);
    menu->addAction(m_spring);

    menuBar()->addMenu(menu);

    connect(m_all, SIGNAL(triggered()), SLOT(showAll()));
    connect(m_summer, SIGNAL(triggered()), SLOT(showSummer()));
    connect(m_winter, SIGNAL(triggered()), SLOT(showWinter()));
    connect(m_fall, SIGNAL(triggered()), SLOT(showFall()));
    connect(m_spring, SIGNAL(triggered()), SLOT(showSpring()));

    QToolBar * full = addToolBar("full");
    full->addAction(m_all);
    full->addSeparator();
    full->addAction(m_summer);
    full->addAction(m_winter);
    full->addAction(m_fall);
    full->addAction(m_spring);

    QToolBar * partial = addToolBar("partial");
    partial->addAction(m_summer);

    setCentralWidget(new CentralWidget(this));
}

void MainWindow::showAll()
{
    QMessageBox::information(this, "info", "all");
    ((CentralWidget *)this->centralWidget())->filterChanged(0);
}
void MainWindow::showSummer()
{
    QMessageBox::information(this, "info", "summer");
    ((CentralWidget *)this->centralWidget())->filterChanged(3);
}
void MainWindow::showWinter()
{
    QMessageBox::information(this, "info", "winter");
    ((CentralWidget *)this->centralWidget())->filterChanged(1);
}
void MainWindow::showFall()
{
    QMessageBox::information(this, "info", "fall");
    ((CentralWidget *)this->centralWidget())->filterChanged(4);
}
void MainWindow::showSpring()
{
    QMessageBox::information(this, "info", "spring");
    ((CentralWidget *)this->centralWidget())->filterChanged(2);
}
